<template>
  <div>
    <!-- 减缓上传减缓材料 -->
    <Card class="marginB10">
      <div class="overflowH f_14 TJ_big">
        <div class="TJ_title f_bold f_16">减缓材料<span class="cRed">*</span></div>

        <div class="TJ_box">

          <div class=" marginB30">

            <div class="marginB20 cRed">(上传减缓材料，请上传jpg图片)</div>


            <template v-for="(val,i) in applicant_list" >
              
              <div class="tran3 jianHuan" :class="val['type']=='工矿企业'?' gongKq ':' '  ">
                <div class="marginB10">申请人{{i+1}}：{{val['name']}}</div>

                <template v-if="$app.judgeData(val['type']) && $app.judgeData($app.delSpace(val['name']))">
                  <div  class="marginB10">
                    <div class="lxl">类型：<span class="cBlue">{{val['type']}}</span></div>
                    <div class="overflowH">
                      <Checkbox v-model="val['is_cost_reduction']" @on-change="wxT(i)" >已完成费减</Checkbox>
                    </div>
                    <div class="clearfix"></div>
                  </div>
                  <template v-if="!val['is_cost_reduction']" >
                    <template v-if="val['type']=='事业单位'||val['type']=='科研单位'||val['type']=='大专院校'">
                      <div>
                        <div class="lxlc">
                          上传材料：<br/>
                          <span class="cRed"></span>
                        </div>
                        <div class="overflowH">
                          <div>
                            <div class="baoG ">
                              <div class="JC_img tran3 pointer textCenter cBlue pullLeft marginB5  relative overflowH">
                                <input type="file"  accept="image/*" class="InputFileBox" @change="btnBWT($event,i,'org_code_path')" />
                                <Icon type="ios-add-circle-outline" style="padding-top:20px;" size="30"/>
                                <div class="f_12"><span class="cRed f_20">*</span>组织机构代码证<br/>(盖公章)</div>
                                <img :src="val['org_code_path'].file_url" v-show="$app.judgeData(val['org_code_path'].file_url)" class="InputShowImg cover" />
                              </div>
                              <div class="bottomText txtOneLine textLine cBlue f_12" @click="$app.openWindow(val['org_code_path'].file_url)" v-show="$app.judgeData(val['org_code_path'].file_url)">查看文件</div>
                            </div>
                          </div>
                        </div>
                        <div class="clearfix"></div>
                      </div>
                    </template>
                    <template v-else-if="val['type']=='个人'">
                      <div>
                        <div class="lxlc">
                          上传材料：<br/>
                          <span class="cRed"></span>
                        </div>
                        <div class="overflowH">
                          <div>
                            <div class="baoG ">
                              <div class="JC_img tran3 pointer textCenter cBlue pullLeft marginB5  relative overflowH">
                                <input type="file"  accept="image/*" class="InputFileBox" @change="btnBWT($event,i,'income_proof_path')" />
                                <Icon type="ios-add-circle-outline" style="padding-top:20px;" size="30"/>
                                <div class="f_12"><span class="cRed f_20">*</span>收入证明<br/>(盖公章)</div>
                                <img :src="val['income_proof_path'].file_url" v-show="$app.judgeData(val['income_proof_path'].file_url)" class="InputShowImg cover" />
                              </div>
                              <div class="bottomText txtOneLine textLine cBlue f_12" @click="$app.openWindow(val['income_proof_path'].file_url)" v-show="$app.judgeData(val['income_proof_path'].file_url)">查看文件</div>
                            </div>

                            <div class="baoG ">
                              <div class="JC_img tran3 pointer textCenter cBlue pullLeft marginB5  relative overflowH">
                                <input type="file"  accept="image/*" class="InputFileBox" @change="btnBWT($event,i,'idcard_path')" />
                                <Icon type="ios-add-circle-outline" style="padding-top:20px;" size="30"/>
                                <div class="f_12 "><span class="cRed f_20">*</span>身份证复印件<br/>(签字)</div>
                                <img :src="val['idcard_path'].file_url" v-show="$app.judgeData(val['idcard_path'].file_url)" class="InputShowImg cover" />
                              </div>
                              <div class="bottomText txtOneLine textLine cBlue f_12" @click="$app.openWindow(val['idcard_path'].file_url)" v-show="$app.judgeData(val['idcard_path'].file_url)">查看文件</div>
                            </div>

                          </div>
                        </div>
                        <div class="clearfix"></div>
                      </div>
                    </template>
                    <template v-else-if="val['type']=='工矿企业'">
                      <div class="marginB10">
                        <div class="lxlc">
                          上传材料：<br/>
                          <span class="cRed"></span>
                        </div>
                        <div class="overflowH">
                          <div>
                            <div class="baoG ">
                              <div class="JC_img tran3 pointer textCenter cBlue pullLeft marginB5  relative overflowH">
                                <input type="file"  accept="image/*" class="InputFileBox" @change="btnBWT($event,i,'business_license_path')" />
                                <Icon type="ios-add-circle-outline" style="padding-top:20px;" size="30"/>
                                <div class="f_12"><span class="cRed f_20">*</span>营业执照复印件<br/>(盖公章)</div>
                                <img :src="val['business_license_path'].file_url" v-show="$app.judgeData(val['business_license_path'].file_url)" class="InputShowImg cover" />
                              </div>
                              <div class="bottomText txtOneLine textLine cBlue f_12" @click="$app.openWindow(val['business_license_path'].file_url)" v-show="$app.judgeData(val['business_license_path'].file_url)">查看文件</div>
                            </div>

                            <div class="baoG ">
                              <div class="JC_img tran3 pointer textCenter cBlue pullLeft marginB5  relative overflowH">
                                <input type="file"  accept="image/*"  class="InputFileBox" @change="btnBWT($event,i,'taxes_form_cover_path')" />
                                <Icon type="ios-add-circle-outline" style="padding:10px 0 5px 0;" size="30"/>
                                <div class="f_12">上一年度企业所得税纳税申报表封面<br/>(盖公章，非必填)</div>
                                <img :src="val['taxes_form_cover_path'].file_url" v-show="$app.judgeData(val['taxes_form_cover_path'].file_url)" class="InputShowImg cover" />
                              </div>
                              <div class="bottomText txtOneLine textLine cBlue f_12" @click="$app.openWindow(val['taxes_form_cover_path'].file_url)" v-show="$app.judgeData(val['taxes_form_cover_path'].file_url)">查看文件</div>
                            </div>
                            
                          </div>
                        </div>
                        <div class="clearfix"></div>
                      </div>
                      <div>
                        <div class="lxlc">
                          多图上传：<br/>
                          <span class="cRed"></span>
                        </div>
                        <div class="overflowH">
                          
                          <div>
                            <div class="baoG ">
                              <div class="JC_img tran3 pointer textCenter cBlue pullLeft marginB5  relative overflowH">
                                <input type="file"  accept="image/*" multiple class="InputFileBox" @change="btnBVA($event,i,'a_class_table_path')" />
                                <Icon type="ios-add-circle-outline" style="padding:10px 0 5px 0;" size="30"/>
                                <div class="f_12">A 类主表复印件<br/>(每页盖公章，非必填)</div>
                              </div>
                            </div>
                            <div class="baoG " v-for="(jar,r) in val['a_class_table_path']" :key="`a_${r}`">
                              <div class="JC_img tran3 pointer  pullLeft marginB5  relative overflowH">
                                <img :src="jar.file_url" class="InputShowImg cover" @click="$app.openWindow(jar.file_url)" />
                                <Icon type="md-close" class="absolute cRed bgWhite " style="top:0;z-index:40;right:0;" size="16" @click="val['a_class_table_path']=$app.arrayDelOne(val['a_class_table_path'],r)"/>
                              </div>
                            </div>
                            
                          </div>
                        </div>
                        <div class="clearfix"></div>
                      </div>
                    </template>

                    

                  </template>
                  <template v-else>
                    <div class="f_20 cCCC lineH2 textCenter" :style="(val['type']!='工矿企业')?'padding-top:25px;':''">无需上传材料</div>
                  </template>
                </template>
                <template v-else>
                  <div class="f_20 cCCC textCenter" style="padding-top:45px;">
                    请填写，申请人 和 申请人类型
                  </div>
                </template>
                

              </div>
            </template>


          </div>

        </div>
      </div>
    </Card>

  
  </div>
</template>


<style lang="less" scoped>
.jianHuan{
  width: 410px;
  height: 220px;
  padding:10px 15px;
  float: left;
  margin: 0 20px 20px 0;

  background-color: #fafafa;
  border-radius: 5px;
  border: 1px solid #eee;
  overflow: hidden;
  .lxl{width: 150px;float: left;}
  .lxlc{width: 90px;float: left;}
  .baoG{
    float: left;
    display:block;
    margin-right: 20px;
    .JC_img{
      height:120px;
      width:120px;
      background-color: white;
    }
    .bottomText{
      width:120px;
      clear: both;
      text-align: center;
    }
  }
  .baoG:last-of-type{
    margin-right: 0;
  }
  
}
.jianHuan.gongKq{height: auto;width: 840px; margin-right: 0;float:none; }
</style>



<script>
import SM1 from "@$@/img/wwss1.jpg";
import cost_reduction from "@$@/js/$common/cost_reduction";
export default {
  name: "jianHuan_box",
  components: {},
  data() {
    let data = {};

    let tool={};
    return Object.assign(data, tool);
  },
  props:['applicant_list'],//父级传值
  watch:{
    applicant_list(newVal,oldVal){
      console.log('applicant_list = ',newVal)
    }
  },
  mounted() {
    
  },
  methods: {
    // 费减材料上传和取消框
    wxT(i){
      cost_reduction.init(this,this.applicant_list[i]);
    },


    // 单图上传
    btnBWT(e,i,textStr){
      let file = e.target.files[0];//选中的文件
      //格式判断
      $app.suffix.jpgPng(e,file,false,()=>{
        $app.selectFileImage(null,null,file,2,resData=>{
          this.$set(this.applicant_list[i],textStr,resData);
        });
      });
    },

    // 单图上传
    btnBWT(e,i,textStr){
      let file = e.target.files[0];//选中的文件
      //格式判断
      $app.suffix.jpgPng(e,file,false,()=>{
        $app.selectFileImage(null,null,file,2,resData=>{
          this.$set(this.applicant_list[i],textStr,resData);
        });
      });
    },

    // 多图上传
    btnBVA(e,i,textStr){
      // 文件循环
      $app.suffixEach(e,file=>{
        //格式判断 多文件上传 尾巴要加 true
        $app.suffix.jpgPng(e,file,false,()=>{
          $app.selectFileImage(null,null,file,2,resData=>{
            // a_class_table_path 为空，转成数组
            if(!$app.judgeData(this.applicant_list[i][textStr])){
              this.applicant_list[i][textStr]=[];
            }
            this.applicant_list[i][textStr].push(resData);
          });
        },true);
      });
    },

		
  }
};
</script>

